<template>
  <div>
<table class="table table-bordered">
    <tr>
      <td align="right">投资名称</td>
      <td>
        <input type="text" v-model="state.data.Mname">
      </td>
    </tr>
    <tr>
      <td align="right">投资总额度</td>
      <td>
        <input type="text" v-model="state.data.HAVE">
      </td>
    </tr>
    <tr>
      <td align="right">已投资额度</td>
      <td>
        <input type="text" v-model="state.data.Ymoney">
      </td>
    </tr>
    <tr>
      <td align="right">剩余额度</td>
      <td>
        <input type="text" v-model="state.data.Smoney">
      </td>
    </tr>
    <tr>
      <td align="right">投资人数</td>
      <td>
        <input type="text"v-model="state.data.Numopp">
      </td>
    </tr>
    <tr>
      <td align="right"></td>
      <td>
        <input type="button" value="提交" class="btn btn-success" @click="ShowAdd">
      </td>
    </tr>
</table>
  </div>
</template>

<script setup lang="ts">

import{reactive,toRefs}from'vue'

import axios from'axios'

import {useRouter}from'vue-router'



const router=useRouter()

let state=reactive({

  data:{
    Mname:'',
    HAVE:'',
    Ymoney:'',
    Smoney:'',
    Numopp:''

  }



})

let {data}=toRefs(state)
//添加
const ShowAdd=(()=>{


  axios({

    url:'https://localhost:44389/api/Default/showAdd',
    method:"post",
    data:data.value,



  })

  .then(res=>{

    if(res.data.data>0)
    {
   alert('添加成功');
    router.push('/demo2')
    }


  })

  .catch(err=>{
    alert('添加失败');
  })


})







</script>

<style scoped>

</style>